package com.boho.system.action;


             
/**
 *
 * @File name:  ValidatorPermissionAction.java   验证用户操作权限
 * @Create on:  2010-05-10 11:27:203
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 * 
 */
           
        

            
import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.service.MessageService;

import com.boho.system.service.PermissionService;



public class ValidatorPermissionAction extends ActionImp {
	
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("FSTI_SYS_PERMISSION_1003", MessageService.getMessage("FSTI_SYS_PERMISSION_1003"),"【系统】", ex);
		}
	}
	@SuppressWarnings("unchecked")
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		String permissionName = atx.getStringValue("PERMISSION_NAME");
		String[] permissionNameArray = permissionName.split(",");
		String actionName = atx.getStringValue("ACTION_NAME");
		String[] actionNameArray = actionName.split(",");
		DynaBeanMap dbm = PermissionService.hasPermission(atx, permissionNameArray, actionNameArray);
		atx.setObjValue("PERMISSION", dbm);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		return 1;
	}
}
